package com.api.server.controller;


import com.api.server.pojo.Controller;
import com.api.server.pojo.Result;
import com.api.server.pojo.Zfadministrator;
import com.api.server.service.IControllerService;
import com.api.server.service.IUserService;
import com.api.server.service.IZfadministratorService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author shi
 * @since 2022-04-28
 */
@RestController
@RequestMapping("/zfadministrator")
public class ZfadministratorController {
    @Autowired
    IUserService userService;
    @Autowired
    IZfadministratorService zfadministratorService;

    // 管理者注册

    @ApiOperation(value = "添加政府超级管理员")
    @PostMapping
    public Result registerzfadministrator(@RequestBody Zfadministrator zfadministrator){
        if (userService.getAdminByUserName(zfadministrator.getUseraccount())!=null){
            return Result.fail("该用户名已经被使用！");

        }
        zfadministratorService.registercontroller(zfadministrator);
        zfadministrator.setUserpassword(null);
        return Result.success(201,"用户创建成功",zfadministrator);
    }
}
